package org.go.scheduler.database.delegate;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.go.spi.ClassLoadHelper;
import org.slf4j.Logger;

/**
 * Quartz JDBC delegate for DB2 v8 databases.
 * <p>
 * This differs from the <code>StdJDBCDelegate</code> in that it stores 
 * <code>boolean</code> values in an <code>integer</code> column.
 * </p>
 * 
 * @author Blair Jensen
 */
public class DB2v8Delegate extends StdJDBCDelegate {

	public DB2v8Delegate(Logger log, String tablePrefix, String schedName, String instanceId, Boolean useProperties, ClassLoadHelper classLoadHelper) {
		super(log, tablePrefix, schedName, instanceId, classLoadHelper, useProperties);
	}

	public DB2v8Delegate(Logger logger, String tablePrefix, String schedName, String instanceId, ClassLoadHelper classLoadHelper) {
		super(logger, tablePrefix, schedName, instanceId, classLoadHelper);
	}

	/**
	 * Sets the designated parameter to the given Java <code>boolean</code> value.
	 * This translates the boolean to 1/0 for true/false.
	 */
	@Override
	protected void setBoolean(PreparedStatement ps, int index, boolean val) throws SQLException {
		ps.setInt(index, ((val) ? 1 : 0));
	}
}
